#include "widget.h"
#include "ui_widget.h"
#include<QTimer>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    srand(time(0));//设下时间戳以便rand生成不同的随机数
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_no_clicked()
{
    ui->label->setText("MAN!!!you are right");
    QTimer::singleShot(2000, this, &Widget::close); // 1000毫秒 = 1秒
    //this->close();

}


void Widget::on_pushButton_yes_clicked()
{
    int width=this->geometry().width();
    int height=this->geometry().height();

    int x=rand()%width;
    int y=rand()%height;
    ui->pushButton_yes->move(x,y);
}

